package ve.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class ScoreDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long idScoreDomain;

    @ManyToMany(targetEntity=ScoreCard.class) @JoinTable(name="ScoreCardDomain", joinColumns=@JoinColumn(name="idScoreDomain"),
    inverseJoinColumns=@JoinColumn(name="idScoreCard")) private Collection<ScoreCard> scoreCards;

    @ManyToMany(targetEntity=Person.class) @JoinTable(name="PersonScoreDomain", joinColumns=@JoinColumn(name="idScoreDomain"),
    inverseJoinColumns=@JoinColumn(name="idPerson")) private Collection<Person> persons;

    @ManyToMany(targetEntity=Cluster.class) @JoinTable(name="ClusterScoreDomain", joinColumns=@JoinColumn(name="idScoreDomain"),
    inverseJoinColumns=@JoinColumn(name="idCluster")) private Collection<Cluster> clusters;

    @Column(columnDefinition="text") private String name;

    @Column(columnDefinition="text") private String description;

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Collection<Cluster> getClusters() {
        return clusters;
    }

    public void setClusters(Collection<Cluster> clusters) {
        this.clusters = clusters;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Collection<Person> getPersons() {
        return persons;
    }

    public void setPersons(Collection<Person> persons) {
        this.persons = persons;
    }

    public Long getIdScoreDomain() {
        return idScoreDomain;
    }

    public Collection<ScoreCard> getScoreCards() {
        return scoreCards;
    }

    public void setScoreCards(Collection<ScoreCard> scoreCards) {
        this.scoreCards = scoreCards;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idScoreDomain != null ? idScoreDomain.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof ScoreDomain)) {
            return false;
        }
        ScoreDomain other = (ScoreDomain) object;
        if ((this.idScoreDomain == null && other.idScoreDomain != null) || (this.idScoreDomain != null && !this.idScoreDomain.equals(other.idScoreDomain))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.ScoreDomain[id=" + idScoreDomain + "]";
    }

}//ends of class
